package org.evolver.disser;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;

public class MainAppPanel extends JPanel {
    private InputPanel      inputPanel;
    private OutputPanel     outputPanel;
    private InputVariables  inputVars;
    
    public MainAppPanel() {
        MigLayout outputLayout = new MigLayout("", "[left][right]", "[top]");
        setLayout(outputLayout);

        // Instantiate both sub-panels
        inputVars   = new InputVariables();
        inputPanel  = new InputPanel(inputVars);
        outputPanel = new OutputPanel();

        // Add them to my main panel
        add(inputPanel);
        add(outputPanel, "wrap");

        JButton     calcButton = new JButton("Расчет");
        calcButton.addActionListener(
                new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        runCalculations();
                    }
                }
                );
        add(calcButton, "span 2, center");
    }

    private void runCalculations() {
//        InputData   myInputData = inputPanel.buildInputData();
//        outputPanel.showText("Тада!");
        outputPanel.showText(inputVars.toString());
    }
}
